<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	template="/templates/userLayout.xhtml">

	<ui:define name="pageTitle">#{out.index_title}</ui:define>

	<ui:define name="head-extra">
		<!-- custom css -->

	</ui:define>

	<ui:define name="dialogs">
		<p:dialog header="Order" widgetVar="orderDialog" modal="true"
			height="400" width="600" style="background: white !important;">
			<h:form id="orderList">
				<h2>Order details</h2>
				<br />
				<p:panelGrid columns="2" style="margin: 0 auto; width: 300;"
					rendered="#{partnerOrderStatusController.selectedOrder!=null}">
					<h:outputText value="Date" />
					<h:outputText
						value="#{partnerOrderStatusController.selectedOrder.date}" />

					<h:outputText value="Cost of all" />
					<h:outputText
						value="#{partnerOrderStatusController.selectedOrder.costOfAll}" />

					<h:outputText value="Status" />
					<h:outputText
						value="#{partnerOrderStatusController.selectedOrder.status}" />
				</p:panelGrid>
				<br />
				<h2>Product list</h2>
				<br />
				<p:dataTable
					rendered="#{partnerOrderStatusController.selectedOrderRegisry!=null}"
					value="#{partnerOrderStatusController.selectedOrderRegisry}"
					var="product">
					<p:column headerText="Name">
						<h:outputText value="#{product.product.name}" />
					</p:column>
					<p:column headerText="Price of 1 product">
						<h:outputText
							value="#{product.product.isSpecial?product.product.specialPrice:product.product.price}" />
					</p:column>
					<p:column headerText="Quantity">
						<h:outputText value="#{product.quantity}" />
					</p:column>
					<p:column headerText="Cost">
						<h:outputText value="#{product.cost}" />
					</p:column>
				</p:dataTable>
			</h:form>
		</p:dialog>
	</ui:define>

	<ui:define name="content">
		<h:form id="partnerProfile"
			rendered="#{partnerOrderStatusController.selectedPartner!=null}">
			<h1>Orders</h1>
			<p:dataTable value="#{partnerOrderStatusController.orders}"
				var="order">
				<p:column headerText="Date">
					<h:outputText value="#{order.date}" />
				</p:column>
				<p:column headerText="Cost of all">
					<h:outputText value="#{order.costOfAll}" />
				</p:column>
				<p:column headerText="Status">
					<h:outputText value="#{order.status}" />
				</p:column>
				<p:column headerText="Details">
					<p:commandButton value="Show details" update=":orderList"
						action="#{partnerOrderStatusController.setOrderRegistry(order)}"
						onclick="PF('orderDialog').show();" />
				</p:column>
			</p:dataTable>

		</h:form>
	</ui:define>
</ui:composition>